#include	"lp_global_vars.h"

//------------------------------------------------------------------------------
int create_tcp_client_socket(int port, const char *ip) {
	struct sockaddr_in server_addr;
	int e = -1;
	int sid;
//	memset(&server_addr, '\0', sizeof(struct sockaddr_in));

	sid = socket(AF_INET, SOCK_STREAM, 0);

	server_addr.sin_family = AF_INET;
	server_addr.sin_addr.s_addr = inet_addr(ip);
	server_addr.sin_port = htons(port);

	while (e < 0) {
		e = connect(sid, (struct sockaddr*) &server_addr, sizeof(struct sockaddr));
		if (e >= 0)
			break;
		close(sid);
		sleep(1);
		sid = socket(AF_INET, SOCK_STREAM, 0);
	}
	return sid;
}
//------------------------------------------------------------------------------
